﻿@model Classified.Domain.Entities.Location
<h2>

        Find Your Ads in @ViewBag.locationName

    <a class="drop-icon" href="@Url.Action("LocationList", "Home")" id="changemylocation">
        Change Location<b class="caret"></b></a>
</h2>
<script language="javascript" type="text/javascript">
    function clearErrors() {
        $('#msgErrorNewLocationDetails').html('');
        $('#msgError').html('');
    }

    function writeError(control, msg) {
        var err_msg = '<div class="alert-message error"><a class="close" href="#">×</a><p>' + msg + '</p></div>';
        $('#' + control).html(err_msg);
    }

    $(document).ready(function () {

        $('.closeModal').live('click', function () {
            $('#my-modal').modal('hide');
        });

        $('#my-modal form').live('submit', function () {
            clearErrors();

            $.post($(this).attr('action'), $(this).serialize(), function (data, status) {
                if (data == 'success') {
                    location.reload();
                }

                //   $('#my-modal').modal('hide');
                // $("#locationDetailsList").html(data);

            }).error(function (error, status, a, b) {
                writeError('msgError', 'Error processing request. Please check errors and try again!');
                $('.modal-body p.body').html(error.responseText);

            });
            return false;
        });

        function getRequest(url) {
            $.ajax({
                url: url,
                context: document.body,
                success: function (data) {
                    $('.modal-body p.body').html(data);
                    $(this).addClass("done");
                    $('#my-modal').modal('show');
                    $('#Article').focus();
                },
                error: function (err) {
                    writeError('msgErrorNewLocationDetails', err);
                }
            });
        }

        $('#changemylocation').live('click', function () {
            clearErrors();


            var url = '@Url.Action("LocationList","Home")';

            getRequest(url);

            return false;
        });

    }); 
</script>
<div id="my-modal" class="modal hide fade" style="width: 612px;">
    <div class="modal-header">
        <a href="Javascript:void(0);" class="closeModal close">&times;</a>
        <h3>
          @if (Model != null)
          {
              if (Model.Name != null)
               {
                   <text> Set Your City & State in @Model.Countries.Name</text>

               }

               else
               {
                   <text>Set Your City & State</text>
               }
          }
            
            

        </h3>
    </div>
    <div class="modal-body">
        <div id="msgError">
        </div>
        <p class="body">
        </p>
    </div>
    <div class="modal-footer">
    </div>
</div>
